<?php
$clr=array_key_exists("c",$_GET)?$_GET["c"]:"FFFFFF";
$frm=array_key_exists("frm",$_GET)?$_GET["frm"]:"";
$fld=array_key_exists("fld",$_GET)?$_GET["fld"]:"";

$r=hexdec(substr($clr,0,2));
$g=hexdec(substr($clr,2,2));
$b=hexdec(substr($clr,4,2));


?>
<html>
<head>
<title>DOUTORMUNDO COLOR PICKER</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<style type="text/css">
<!--
.td1 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; color: #000000; background-color: #EEEEDF}
.td2 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; color: #000000; background-color: #CCCCCC}
.link { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #000000; text-decoration: none}
.linkGrande { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #FF0000; text-decoration: none ; font-weight: bold}
.txtOutras { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; color: #FF0000; text-decoration: none }
.txtCaixa { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #000000; text-decoration: none }
.titleCaixa { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20pt; color: #000000; text-decoration: none ; font-weight: bold}
.subtitleCaixa { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #000000; text-decoration: none ; font-weight: bold }
.table		{border-width:0;background-color:#EEEDF;font-face:verdana}
.inputHex		{width:80px;font-face:verdana}
div.maxcolorbar	{width:256;height:16;border-color:#0080FF;border-style:inset;position:relative}
div.colorbar	{width:256;height:100%;cursor:hand}
.inputCores { width:80px;font-face:verdana ; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9pt; color: #000000; background-color: #FFFFFF}
.linkGrandeOver { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #000000; text-decoration: none ; font-weight: bold }
.txtOutrasOver { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; color: #000000; text-decoration: none }
-->
</style>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
function setIt(obj,obj2){
  k=eval("window.opener.document."+obj+"."+obj2);
  k.value=document.color.tot.value;
  window.opener.arrumaCorTD(document.color.tot.value);
  window.close();
}

//-->
</script>
<script language="JavaScript">


<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function reload() {   //adivinha
	window.location.reload();
		}

// se fosse dropdown Menu
/* function menuApagado() {  //troca cor do menuApagado
	var cor = document.form1.cor.options[document.form1.cor.selectedIndex].value;
	eval("MM_changeProp('menu1','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('eMais','','style.backgroundColor','" + cor + "','DIV')");
	}
	*/

function menuApagado() {  //troca cor do menuApagado
	var cor = document.form1.corAp.value;
	eval("MM_changeProp('menu1','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('menu2','','style.backgroundColor','" + cor + "','DIV'); MM_changeProp('menu3','','style.backgroundColor','" + cor + "','DIV'); MM_changeProp('menu4','','style.backgroundColor','" + cor + "','DIV'); MM_changeProp('menu5','','style.backgroundColor','" + cor + "','DIV'); MM_changeProp('eMais','','style.backgroundColor','" + cor + "','DIV')");
	}

function menuOver() {  //troca cor do menuOver
	var cor = document.form2.corOver.value;
	eval("MM_changeProp('menuOver','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('menuOver2','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('menuOver3','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('menuOver4','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('menuOver5','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('outras','','style.backgroundColor','" + cor + "','DIV'); MM_changeProp('outrasOver','','style.backgroundColor','" + cor + "','DIV')");
	}

function menuSel() {  //troca cor do menuOver
	var cor = document.form3.corSel.value;
	eval("MM_changeProp('menuSelecionado','','style.backgroundColor','" + cor + "','DIV');MM_changeProp('outras1','','style.color','"+ cor +"','DIV');MM_changeProp('outras2','','style.color','"+ cor +"','DIV');MM_changeProp('outras3','','style.color','"+ cor +"','DIV');MM_changeProp('outras4','','style.color','"+ cor +"','DIV');MM_changeProp('outras5','','style.color','"+ cor +"','DIV');MM_changeProp('caixa','','style.backgroundColor','"+ cor +"','DIV'); MM_changeProp('shopping','','style.backgroundColor','"+ cor +"','DIV')");
	}

function menuFont() {  //troca cor da fonte do menu
	var cor = document.form4.corFont.value;
	eval("MM_changeProp('apagado','','style.color','"+ cor +"','');MM_changeProp('apagado2','','style.color','"+ cor +"',''); MM_changeProp('apagado3','','style.color','"+ cor +"',''); MM_changeProp('apagado4','','style.color','"+ cor +"',''); MM_changeProp('apagado5','','style.color','"+ cor +"',''); MM_changeProp('caixaTitle','','style.color','"+ cor +"',''); MM_changeProp('over','','style.color','"+ cor +"',''); MM_changeProp('over2','','style.color','"+ cor +"',''); MM_changeProp('over3','','style.color','"+ cor +"',''); MM_changeProp('over4','','style.color','"+ cor +"',''); MM_changeProp('over5','','style.color','"+ cor +"',''); MM_changeProp('subtitleCaixa','','style.color','"+ cor +"',''); MM_changeProp('txtCaixa','','style.color','"+ cor +"',''); MM_changeProp('eMaisTitle','','style.color','"+ cor +"',''); MM_changeProp('shoppingTitle','','style.color','"+ cor +"',''); MM_changeProp('selecionado','','style.color','"+ cor +"',''); MM_changeProp('logo','','style.color','"+ cor +"',''); MM_changeProp('outras6','','style.color','"+ cor +"','DIV');MM_changeProp('outras7','','style.color','"+ cor +"','DIV');MM_changeProp('outras8','','style.color','"+ cor +"','DIV');MM_changeProp('outras9','','style.color','"+ cor +"','DIV');MM_changeProp('outras10','','style.color','"+ cor +"','DIV');");
	}

//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="2" topmargin="2" marginwidth="2" marginheight="2">
<!--div id="Layer2" style="position:absolute; left:10px; top:13px; width:439px; height:161px; z-index:3"-->
  <form name="color">
  <table class="table" border="0" cellspacing="0" cellpadding="5" width="400" bgcolor="#EEEEDF">

    <col width="50"> <col width="55"> <col width="75"> <col width="260"> <thead>
    <tr>
        <td class="txtCaixa">COR</td>
        <td class="txtCaixa">DEC</td>
        <td class="txtCaixa">HEX</td>
        <td class="txtCaixa">Utilize o mouse para mudar a cor.</td>

    </tr>
    </thead> <tbody>
    <tr>
      <td class="txtCaixa" style="color:#FF0000">VERMELHO</td>
      <td>
        <input type="text" onchange="r='r';checkb()" size="3" maxlength="3" name="r1" value="0">
      </td>
      <td>
        <input type="text" onchange="r='r';checka()" size="2" maxlength="2" name="r2" value="00">
      </td>

      <td>
        <div class="maxcolorbar" >
          <div style="background-color:#800000" class="colorbar" onmousedown="r='r';checkc(event)" onmousemove="m(event)" onmouseup="y=''" onselectstart="event.returnValue=false;return false">
            <div style="background-color:#FF0000;width:0;height:100%" id="rb">
            </div>
          </div>
        </div>
      </td>
    </tr>
    <tr>
      <td class="txtCaixa" style="color:#00FF00">VERDE</td>

      <td>
        <input type="text" onchange="r='g';checkb()" size="3" maxlength="3" name="g1" value="0">
      </td>
      <td>
        <input type="text" onchange="r='g';checka()" size="2" maxlength="2" name="g2" value="00">
      </td>
      <td>
        <div class="maxcolorbar" >
          <div style="background-color:#008000" class="colorbar" onmousedown="r='g';checkc(event)" onmousemove="m(event)" onmouseup="y=''"onselectstart="event.returnValue=false;return false">
            <div style="background-color:#00FF00;width:0;height:100%" id="gb">
            </div>
          </div>

        </div>
      </td>
    </tr>
    <tr>
      <td class="txtCaixa" style="color:#0000FF">AZUL</td>
      <td>
        <input type="text" onchange="r='b';checkb()" size="3" maxlength="3" name="b1" value="0">
      </td>
      <td>
        <input type="text" onchange="r='b';checka()" size="2" maxlength="2" name="b2" value="00">

      </td>
      <td>
        <div class="maxcolorbar">
          <div style="background-color:#000080" class="colorbar" onmousedown="r='b';checkc(event)" onmousemove="m(event)" onmouseup="y=''"onselectstart="event.returnValue=false;return false">
            <div style="background-color:#0000FF;width:0;height:100%" id="bb">
            </div>
          </div>
        </div>
      </td>
    </tr>
    </tbody> <tfoot>
    <tr>
        <td class="txtCaixa">VALOR RGB</td>

      <td colspan="2">
        <input class="inputHex" type="text" onchange="check()" size="7" maxlength="7" name="tot" value="#000000">
      </td>
      <td class="txtCaixa">
      	<table width=100% border=0>
      		<tr>
      			<td class="txtCaixa" align="right">Cor :</td>
      			<td height=15 width=40>
      				<table width=100% border=1>
      					<tr>
      						<td height=15 width=40 id="ttt" ></td>
      					</tr>
      				</table>
      			</td>
      			<td align=right><input type="button" value="OK" onclick="setIt('<?php echo $frm?>','<?php echo $fld?>');"></td>
      		</tr>
      	</table>
      </td>
    </tr>
    </tfoot>
  </table>
</form>

<script>var r
var y=""
var RB=document.getElementById?document.getElementById("rb"):document.all.rb
var GB=document.getElementById?document.getElementById("gb"):document.all.gb
var BB=document.getElementById?document.getElementById("bb"):document.all.bb
var TOT=document.forms.color.tot
var TTT=document.getElementById?document.getElementById("ttt"):document.all.ttt
var mycolor=new Object()
mycolor.r=<?php echo $r?>;

mycolor.g=<?php echo $g?>;

mycolor.b=<?php echo $b?>;

function numtohex(input){
 var t="0123456789ABCDEF"
 return (t.charAt(input>>4)+t.charAt(input%16))}
function s(){
 document.forms.color.r1.value=mycolor.r
 document.forms.color.g1.value=mycolor.g
 document.forms.color.b1.value=mycolor.b
 document.forms.color.r2.value=numtohex(mycolor.r)
 document.forms.color.g2.value=numtohex(mycolor.g)
 document.forms.color.b2.value=numtohex(mycolor.b)
 RB.style.width=mycolor.r
 GB.style.width=mycolor.g
 BB.style.width=mycolor.b
 TOT.value="#"+numtohex(mycolor.r)+numtohex(mycolor.g)+numtohex(mycolor.b)
 TTT.style.backgroundColor=TOT.value}
function check(){
 var i=TOT.value.toString()
 if(i.charAt(0)=="#")i=i.substr(1,6)
 while(i.length<6)i+="0"
 i=i.toUpperCase()
 var r=i.substr(0,2)
 var g=i.substr(2,2)
 var b=i.substr(4,2)
 if(!r.match(/[^0-9a-fA-F]/i))mycolor.r=parseInt(r,16)
 if(!g.match(/[^0-9a-fA-F]/i))mycolor.g=parseInt(g,16)
 if(!b.match(/[^0-9a-fA-F]/i))mycolor.b=parseInt(b,16)
 s()}
function checka(){
 var i=document.forms.color[r+"2"].value
 while(i.toString().length<2)i="0"+i
 i=i.toUpperCase()
 if(!i.match(/[^0-9a-fA-F]/i))mycolor[r]=parseInt(i,16)
 s()}
function checkb(){
 var i=document.forms.color[r+"1"].value
 if(isNaN(i))i=mycolor[r]
 if(Number(i)>255)i=255
 if(Number(i)<0)i=0
 mycolor[r]=i
 s()}
function checkc(e){
 if(!e)e=event
 if(y==""){
  y=r
  mycolor[r]=parseInt(document.all?e.offsetX:e.layerX)
  s()}}
function m(e){
 if(!e)e=event
 if(y=="")return false
 var x=parseInt(document.all?e.offsetX:e.layerX)
 if(x<0)x=0
 if(x>255)x=255
 mycolor[r]=x
 s()}
changebgcolor=new Function("document.body.style.backgroundColor=TTT.style.backgroundColor")
changetextcolor=new Function("document.body.style.color=TTT.style.backgroundColor")
document.body.onmouseup=new Function("y=''")
s()
</script>
<!--/div-->

</body>
</html>
